package com.ruoyi.web.controller.order;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.order.domain.MesModelNodeRela;
import com.ruoyi.order.service.IMesModelNodeRelaService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 型号与节点关系Controller
 * 
 * @author guoxl
 * @date 2025-06-01
 */
@RestController
@RequestMapping("/order/modelNodeRela")
public class MesModelNodeRelaController extends BaseController
{
    @Autowired
    private IMesModelNodeRelaService mesModelNodeRelaService;

    /**
     * 查询型号与节点关系列表
     */
    @PreAuthorize("@ss.hasPermi('order:modelNodeRela:list')")
    @GetMapping("/list")
    public TableDataInfo list(MesModelNodeRela mesModelNodeRela)
    {
        startPage();
        List<MesModelNodeRela> list = mesModelNodeRelaService.selectMesModelNodeRelaList(mesModelNodeRela);
        return getDataTable(list);
    }

    /**
     * 导出型号与节点关系列表
     */
    @PreAuthorize("@ss.hasPermi('order:modelNodeRela:export')")
    @Log(title = "型号与节点关系", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MesModelNodeRela mesModelNodeRela)
    {
        List<MesModelNodeRela> list = mesModelNodeRelaService.selectMesModelNodeRelaList(mesModelNodeRela);
        ExcelUtil<MesModelNodeRela> util = new ExcelUtil<MesModelNodeRela>(MesModelNodeRela.class);
        util.exportExcel(response, list, "型号与节点关系数据");
    }

    /**
     * 获取型号与节点关系详细信息
     */
    @PreAuthorize("@ss.hasPermi('order:modelNodeRela:query')")
    @GetMapping(value = "/{relaId}")
    public AjaxResult getInfo(@PathVariable("relaId") Long relaId)
    {
        return success(mesModelNodeRelaService.selectMesModelNodeRelaByRelaId(relaId));
    }

    /**
     * 新增型号与节点关系
     */
    @PreAuthorize("@ss.hasPermi('order:modelNodeRela:add')")
    @Log(title = "型号与节点关系", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MesModelNodeRela mesModelNodeRela)
    {
        return toAjax(mesModelNodeRelaService.insertMesModelNodeRela(mesModelNodeRela));
    }

    /**
     * 修改型号与节点关系
     */
    @PreAuthorize("@ss.hasPermi('order:modelNodeRela:edit')")
    @Log(title = "型号与节点关系", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MesModelNodeRela mesModelNodeRela)
    {
        return toAjax(mesModelNodeRelaService.updateMesModelNodeRela(mesModelNodeRela));
    }

    /**
     * 删除型号与节点关系
     */
    @PreAuthorize("@ss.hasPermi('order:modelNodeRela:remove')")
    @Log(title = "型号与节点关系", businessType = BusinessType.DELETE)
	@DeleteMapping("/{relaIds}")
    public AjaxResult remove(@PathVariable Long[] relaIds)
    {
        return toAjax(mesModelNodeRelaService.deleteMesModelNodeRelaByRelaIds(relaIds));
    }
}
